home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / src / GLperf3.12-src.lha / GLperf / BitmapG.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-09-19  |  5.8 KB  |  177 lines

  1. /*
  2.  * (c) Copyright 1995, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  * Permission to use, copy, modify, and distribute this software for
  5.  * any purpose and without fee is hereby granted, provided that the above
  6.  * copyright notice appear in all copies and that both the copyright notice
  7.  * and this permission notice appear in supporting documentation, and that
  8.  * the name of Silicon Graphics, Inc. not be used in advertising
  9.  * or publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.
  11.  *
  12.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  13.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  14.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  15.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  16.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  17.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  18.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  19.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  20.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  21.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  22.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  23.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  24.  *
  25.  * US Government Users Restricted Rights
  26.  * Use, duplication, or disclosure by the Government is subject to
  27.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  28.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  29.  * clause at DFARS 252.227-7013 and/or in similar or successor
  30.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  31.  * Unpublished-- rights reserved under the copyright laws of the
  32.  * United States.  Contractor/manufacturer is Silicon Graphics,
  33.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  34.  *
  35.  * Author: John Spitzer, SGI Applied Engineering
  36.  *
  37.  */
  38.  
  39. #include <stdio.h>
  40. #include <stdlib.h>
  41. #include "FuncEnum.h"
  42. #include <malloc.h>
  43.  
  44. /* This will be set by compile time #defines                     */
  45. /* They control the size and functionality of the code generated */
  46. #ifdef FULL_COLOR_PATHS
  47.   #define MAX_COLOR_DIM 4
  48. #else
  49.   #define MAX_COLOR_DIM 3
  50. #endif
  51. #ifdef FULL_RASTERPOS_PATHS
  52.   #define MIN_RPOS_DIM 2
  53. #else
  54.   #define MIN_RPOS_DIM 3
  55. #endif
  56. #ifdef FULL_FUNCPTR_PATHS
  57.   #define FUNC_PTRS 1
  58. #else
  59.   #define FUNC_PTRS 0
  60. #endif
  61.  
  62. char* visualSuccinct[] = {
  63.     "Idx",
  64.     "RGB"
  65. };
  66.  
  67. char* colorSuccinct[] = {
  68.     "n",
  69.     "r",
  70. };
  71.  
  72. char* pntSuccinct[] = {
  73.     "Pf",
  74.     "Pt"
  75. };
  76.  
  77. char* subSuccinct[] = {
  78.     "All",
  79.     "Sub"
  80. };
  81.  
  82. char* miSuccinct[] = {
  83.     "One",
  84.     "Multi"
  85. };
  86.  
  87. char* visualVerbose[] = {
  88.     "CI",
  89.     "RGB"
  90. };
  91.  
  92. char* colorVerbose[] = {
  93.     "NONE",
  94.     "PER_RASTERPOS",
  95. };
  96.  
  97. char* PrintEntry(FILE *fp, int p, int sub, int rd, int mi, int c, int cd, int vis)
  98. {
  99.     char* funcName = (char*)malloc(64);
  100.     sprintf(funcName,"Bitmap%s%s%s%sC%s%d%d", visualSuccinct[vis], pntSuccinct[p], subSuccinct[sub], miSuccinct[mi], colorSuccinct[c], rd, cd);
  101.     fprintf(fp,"#define FUNCTION %s\n", funcName);
  102.     if (p)
  103.         fprintf(fp,"#define FUNCTION_PTRS\n");
  104.     if (sub)
  105.         fprintf(fp,"#define SUBIMAGE\n");
  106.     if (mi)
  107.         fprintf(fp,"#define MULTIIMAGE\n");
  108.     fprintf(fp,"#define RASTERPOS_DIM %d\n", rd);
  109.     fprintf(fp,"#define COLOR %s\n", colorVerbose[c]);
  110.     fprintf(fp,"#define COLOR_DIM %d\n", cd);
  111.     fprintf(fp,"#define VISUAL %s\n", visualVerbose[vis]);
  112.     fprintf(fp,"#include \"BitmapX.c\"\n");
  113.     fprintf(fp,"#undef FUNCTION\n");
  114.     fprintf(fp,"#undef VISUAL\n");
  115.     fprintf(fp,"#undef COLOR\n");
  116.     fprintf(fp,"#undef COLOR_DIM\n");
  117.     fprintf(fp,"#undef MULTIIMAGE\n");
  118.     fprintf(fp,"#undef SUBIMAGE\n");
  119.     fprintf(fp,"#undef FUNCTION_PTRS\n");
  120.     fprintf(fp,"#undef RASTERPOS_DIM\n");
  121.     fprintf(fp,"\n");
  122.     return funcName;
  123. }
  124.  
  125. #define TOTAL_FUNCS 2*2*2*2*2*2*2
  126.  
  127. main()
  128. {
  129.     BitmapFunc function;
  130.     int i;
  131.     int p,sub,rd,mi,c,cd,vis;
  132.     FILE *fp, *header;
  133.     char* names[TOTAL_FUNCS];
  134.  
  135.     for (i=0; i<TOTAL_FUNCS; i++)
  136.         names[i] = "Noop";
  137.     header = fopen("BitmapX.h", "w");
  138.     fprintf(header, "/*\n * File BitmapX.h generated from BitmapG (source file BitmapG.c)\n */\n\n");
  139.     fp = fopen("BitmapF.c", "w");
  140.     fprintf(fp, "/*\n * File BitmapF.c generated from BitmapG (source file BitmapG.c)\n */\n\n");
  141.     fprintf(fp, "#include \"Bitmap.h\"\n");
  142.     for (mi=0;mi<2;mi++) {
  143.         for (sub=0;sub<2;sub++) {
  144.             for (p=0;p<=FUNC_PTRS;p++) {
  145.                 for (rd=MIN_RPOS_DIM;rd<=3;rd++) {
  146.                     for (c=0;c<2;c++) {
  147.                         for (vis=0;vis<2;vis++) {
  148.                             for (cd=3;cd<=MAX_COLOR_DIM;cd++) {
  149.                                 function.word = 0;
  150.                                 function.bits.rasterPosDim  = rd-2;
  151.                                 function.bits.functionPtrs  = p;
  152.                                 function.bits.subimage      = sub;
  153.                                 function.bits.multiimage    = mi;
  154.                                 function.bits.colorData     = c;
  155.                                 function.bits.visual        = vis;
  156.                                 function.bits.colorDim      = cd-3;
  157.                                 names[function.word] = PrintEntry(fp, p, sub, rd, mi, c,
  158.                                     cd, vis);
  159.                                 fprintf(header, "void %s(TestPtr);\n", names[function.word]);
  160.                             }
  161.                         }
  162.                     }
  163.                 }
  164.             }
  165.         }
  166.     }
  167.     fclose(fp);
  168.     fprintf(header, "void Noop(TestPtr);\n");
  169.     fprintf(header, "typedef void (*ExecuteFunc)(TestPtr);\n");
  170.     fprintf(header, "\nExecuteFunc BitmapExecuteTable[] = {\n");
  171.     for (i=0; i<TOTAL_FUNCS; i++)
  172.         fprintf(header, "    %s,\n", names[i]);
  173.     fprintf(header, "};\n");
  174.     fclose(header);
  175.     return 0;
  176. }
  177.